import {HTTP} from '@/utils/HTTP.js'
import {useState, useEffect} from "react";

// 异步请求频道数据
const useChannels = () => {
    const [channelsList, setChannelsList] = useState([])

    // console.log(res)
    useEffect(() => {

        async function getChannels() {
            const res = await HTTP({
                url: '/api/channels',
                method: 'GET'
            })
            setChannelsList(res.data)
        }
        getChannels()

    }, [])

    return {channelsList}
}

export default useChannels